
export default {
    /**
     * 阿里云文件夹目录m枚举
     * @type {{}}
     */
    DIR_LIST: {
        /**
         * 活动图片
         */
        activity: 'activity',
        /**
         * 模板图片
         */
        mod: 'mod',
        /**
         * 默认文件夹
         */
        default: 'default'
    },
    IMAGE_SERVER: process.env.VUE_APP_IMAGE_SERVER,
    OSS_SERVER: process.env.VUE_APP_OSS,
    withPrefix(url) {
        if (!url) {
            return '';
        }
        // 临时兼容两种文件地址
        // 1. activity_music/2018/12/26/1545820964230.jpg
        if (url.startsWith('http')) {
            return url;
        }
        if (url.startsWith('activity_music')) {
            return this.IMAGE_SERVER + url;
        } else {
            // 新版阿里云地址
            return this.OSS_SERVER + url;
        }
    },
    withPrefixForList(list) {
        return list.map(item => this.withPrefix(item));
    },
    removePrefix(url) {
        return url.replace(this.IMAGE_SERVER, '').replace(this.OSS_SERVER, '');
    },
    wxAvatar(url) {
        return url.replace('http://thirdwx.qlogo.cn/', process.env.VUE_APP_WX_IMAGE_SERVER);
    }
};
